package com.fun.arithmetic;

public class Kmp {
    public static void getNext(String p,int[] next){
       int pLength=p.length();
       //p的下标
       int i=0;
       int j=-1;
       next[0]=-1;
       while (i<pLength){
           if(j==-1||p.charAt(i)==p.charAt(j)){
              i++;
              j++;
              next[i]=j;
           }else{
               j=next[j];
           }
       }
    }
}
